"""
文件名: HomeController.py
作用: 首页内容管理的接口,每一个接口都有一个对应的方法,该方法用于测试用例
作者: 姜黎
"""

from Untils.SendMethod import SendMethod


class HomeController:
    def __init__(self):
        self.url = 'http://139.159.146.104:8083'

    def content(self):
        """
        首页内容页信息展示
        :return: 首页内容
        """
        url = self.url + "/home/content"
        return SendMethod.send_method(method="get", url=url)

    def product_cate_list(self, parentId):
        """
        获取首页商品分类
        :return:
        """
        url = self.url + f"/home/productCateList/{parentId}"
        return SendMethod.send_method(method="get", url=url)

    def recommend_product_list(self):
        """
        分页获取推荐商品
        :return:
        """
        payload = {
            'pageSize': '30',
            'pageNum': '1'
        }
        url = self.url + "/home/recommendProductList"
        return SendMethod.send_method(method="get", url=url, params=payload)

    def subject_list(self, cateId):
        """
        根据分类获取专题
        :return:
        """
        payload = {
            'cateId': cateId,
            'pageSize': '4',
            'pageNum': '1'
        }
        url = self.url + "/home/subjectList"
        return SendMethod.send_method(method="get", url=url, params=payload)


if __name__ == '__main__':
    hc = HomeController()
    print(hc.subject_list(1))
